<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * form组件的父类,提供默认的属性,和方法
<span class='line'>  3</span>  * @param options 参见{@link #getOptions}返回的对象
<span class='line'>  4</span>  * @constructor
<span class='line'>  5</span>  */</span><span class="WHIT">
<span class='line'>  6</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">FDComponent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  7</span> </span><span class="WHIT">	</span><span class="NAME">FDLib.implement</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="NAME">FDControl</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  8</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>  9</span> </span><span class="WHIT">	</span><span class="NAME">this.options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FDLib.util.apply</span><span class="PUNC">(</span><span class="NAME">this.getOptions</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="WHIT">	</span><span class="NAME">this.outerDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="NAME">FDTag.DIV</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT">	</span><span class="NAME">this.hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">FDLib.util.isString</span><span class="PUNC">(</span><span class="NAME">this.options.domId</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT">		</span><span class="NAME">this.renderTo</span><span class="PUNC">(</span><span class="NAME">this.options.domId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 18</span> 
<span class='line'> 19</span> </span><span class="NAME">FDComponent.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="COMM">/**
<span class='line'> 21</span>  * 获取组件的默认属性
<span class='line'> 22</span>    @return &lt;pre>&lt;code>返回json数据类型
<span class='line'> 23</span> {
<span class='line'> 24</span> 	domId:null // 定位的节点ID
<span class='line'> 25</span> 	,label:"" // 控件前面要显示的文字
<span class='line'> 26</span> 	,labelAlign:'right' // label水平对齐方式
<span class='line'> 27</span> 	,labelValign:'middle' // label垂直对齐方式
<span class='line'> 28</span> 	,name:"" // 控件的name
<span class='line'> 29</span> 	,width:"" // 控件的宽,如'120px'
<span class='line'> 30</span> 	,height:"" // 控件的高,如'30px'
<span class='line'> 31</span> 	,validates:[] // 验证类
<span class='line'> 32</span> }&lt;/code>&lt;/pre>
<span class='line'> 33</span>  */</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">	</span><span class="NAME">getOptions</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">			</span><span class="NAME">domId</span><span class="PUNC">:</span><span class="KEYW">null</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="NAME">label</span><span class="PUNC">:</span><span class="STRN">""</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="NAME">labelAlign</span><span class="PUNC">:</span><span class="STRN">'right'</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="NAME">labelValign</span><span class="PUNC">:</span><span class="STRN">'middle'</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="NAME">name</span><span class="PUNC">:</span><span class="STRN">""</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="NAME">width</span><span class="PUNC">:</span><span class="STRN">""</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="NAME">height</span><span class="PUNC">:</span><span class="STRN">""</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="NAME">validates</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 47</span> 	 * 显示控件
<span class='line'> 48</span> 	 */</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="NAME">show</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">		</span><span class="NAME">this.outerDiv.style.display</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"inline-block"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 53</span> 	 * 隐藏控件
<span class='line'> 54</span> 	 */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="NAME">hide</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">		</span><span class="NAME">this.outerDiv.style.display</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"none"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 59</span> 	 * 设置控件样式
<span class='line'> 60</span> 	 * @param style className,字符串格式
<span class='line'> 61</span> 	 */</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="NAME">setStyle</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">FDLib.util.isString</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">			</span><span class="NAME">this.outerDiv.className</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 68</span> 	 * 设置控件样式,作用同setStyle
<span class='line'> 69</span> 	 * @param className className,字符串格式
<span class='line'> 70</span> 	 */</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="NAME">setClass</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">className</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">		</span><span class="NAME">this.setStyle</span><span class="PUNC">(</span><span class="NAME">className</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 75</span> 	 * 添加控件样式.&lt;br>
<span class='line'> 76</span> 	 * &lt;b>注:此样式添加在控件的最外层的div上&lt;/b>
<span class='line'> 77</span> 	 * @param className className,字符串格式
<span class='line'> 78</span> 	 */</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="NAME">addClass</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">className</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">		</span><span class="NAME">FDLib.dom.addClass</span><span class="PUNC">(</span><span class="NAME">this.outerDiv</span><span class="PUNC">,</span><span class="NAME">className</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 83</span> 	 * 移除控件样式
<span class='line'> 84</span> 	 * @param className className,字符串格式
<span class='line'> 85</span> 	 */</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="NAME">removeClass</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">className</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">		</span><span class="NAME">FDLib.dom.removeClass</span><span class="PUNC">(</span><span class="NAME">this.outerDiv</span><span class="PUNC">,</span><span class="NAME">className</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> 
<span class='line'> 91</span> </span></pre></body></html>